/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package documenteditor.entidade.model;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.hibernate.annotations.Cascade;

/**
 *
 * @author gleidson.moura
 */
@Entity
@Table(name="BRINDE")
@SequenceGenerator(name="GEN_BRINDE", sequenceName="GEN_BRINDE_ID")
@NamedQueries({
    @NamedQuery(name = "Brinde.findAll", query = "SELECT b FROM Brinde b"),
    @NamedQuery(name = "Brinde.findByIdBrinde", query = "SELECT b FROM Brinde b WHERE b.idBrinde = :idBrinde"),
    @NamedQuery(name = "Brinde.findByNomeBrinde", query = "SELECT b FROM Brinde b WHERE b.nomeBrinde = :nomeBrinde"),
    @NamedQuery(name = "Brinde.findByQuantidadeEstoque", query = "SELECT b FROM Brinde b WHERE b.quantidadeEstoque = :quantidadeEstoque"),
    @NamedQuery(name = "Brinde.findByValorParaResgate", query = "SELECT b FROM Brinde b WHERE b.valorParaResgate = :valorParaResgate")})
public class Brinde implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name="ID_BRINDE")
    @GeneratedValue(strategy = GenerationType.AUTO, generator="GEN_BRINDE")
    private Long idBrinde;

    @Column(name="NOME_BRINDE", nullable=false)
    private String nomeBrinde;

    @Column(name="QUANTIDADE_ESTOQUE")
    private Integer quantidadeEstoque;

    @Column(name="VALOR_PARA_RESGATE")
    private Double valorParaResgate;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "idClienteBrinde.brinde",
               cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
              org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
    private List<ClienteBrinde> clienteBrinde = new LinkedList<ClienteBrinde>();

    public Long getIdBrinde() {
        return idBrinde;
    }

    public void setIdBrinde(Long idBrinde) {
        this.idBrinde = idBrinde;
    }

    public List<ClienteBrinde> getClienteBrinde() {
        return clienteBrinde;
    }

    public void setClienteBrinde(List<ClienteBrinde> clienteBrinde) {
        this.clienteBrinde = clienteBrinde;
    }

    public String getNomeBrinde() {
        return nomeBrinde;
    }

    public void setNomeBrinde(String nomeBrinde) {
        this.nomeBrinde = nomeBrinde;
    }

    public Integer getQuantidadeEstoque() {
        return quantidadeEstoque;
    }

    public void setQuantidadeEstoque(Integer quantidadeEstoque) {
        this.quantidadeEstoque = quantidadeEstoque;
    }

    public Double getValorParaResgate() {
        return valorParaResgate;
    }

    public void setValorParaResgate(Double valorParaResgate) {
        this.valorParaResgate = valorParaResgate;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idBrinde != null ? idBrinde.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the idBrinde fields are not set
        if (!(object instanceof Brinde)) {
            return false;
        }
        Brinde other = (Brinde) object;
        if ((this.idBrinde == null && other.idBrinde != null) || (this.idBrinde != null && !this.idBrinde.equals(other.idBrinde))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "documenteditor.entidade.model.Brinde[id=" + idBrinde + "]";
    }

}
